using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Afrs.Draco.Prms.Client.Proxy;
using Afrs.Prms.DataObject;

namespace 
{
  /// <summary>
  /// Treleasereason Test Class
  /// </summary>
  [TestClass]
  public class TestTreleasereason
  {
    #region Class Variables
    private CdoPrms<DOTreleasereason>		m_Treleasereason;
    private CdoPrmsList<DOTreleasereason>	m_AllTreleasereason;
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Constructs the test
    /// </summary>
    public TestTreleasereason()
    {
      // Create the data objects
      this.m_Treleasereason	= new CdoPrms<DOTreleasereason>();
      this.m_AllTreleasereason	= new CdoPrmsList<DOTreleasereason>();
    }
    #endregion

    #region Class Methods
    /// <summary>
    /// Retrieves all Treleasereason data objects
    /// </summary>
    [TestMethod]
    public void TreleasereasonRetrieveAll()
    {
      // Set up the data object for list retrieval
      this.m_AllTreleasereason.DataObject = new DOTreleasereason();
      this.m_AllTreleasereason.ListAction = AfrsDOListAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_AllTreleasereason.PerformAction())
      {
        // Assert the errors
        if (this.m_AllTreleasereason.Errors.Count > 0) { Assert.Fail(this.m_AllTreleasereason.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Create a new Treleasereason
    /// </summary>
    [TestMethod]
    public void TreleasereasonCreate()
    {
      // Set up the data object for creation
      this.m_Treleasereason.DataObject.releasereason = "Test releasereason";
      this.m_Treleasereason.DataObject.description = "Test description";
      this.m_Treleasereason.DataObject.active = false;
      this.m_Treleasereason.DataObject.Action = AfrsDataObjectAction.Create;

      // Perform the action and determine the success
      if (!this.m_Treleasereason.PerformAction())
      {
        // Assert the errors
        if (this.m_Treleasereason.Errors.Count > 0) { Assert.Fail(this.m_Treleasereason.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Retrieves a specific Treleasereason
    /// </summary>
    [TestMethod]
    public void TreleasereasonRetrieve()
    {
      // Determine whether the data object needs to be specified
      if (this.m_Treleasereason.DataObject.Id == 0)
      {
        // Specify the data object to retrieve
        this.m_Treleasereason.DataObject.releasereasonid = 10;
      }

      // Set up the data object action for retrieval
      this.m_Treleasereason.DataObject.Action = AfrsDataObjectAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_Treleasereason.PerformAction())
      {
        // Assert the errors
        if (this.m_Treleasereason.Errors.Count > 0) { Assert.Fail(this.m_Treleasereason.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }
    #endregion
  }
}
